package com.lcy.demo.annotation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by PC on 2017/3/29.
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/user")
    public User user(@RequestParam(value = "id",defaultValue = "1") Integer id){
        return userService.getUser(id);
    }

    @RequestMapping("/insertUser")
    public Integer insertUser(@RequestParam(value = "name") String name,
                              @RequestParam(value = "age") Integer age,
                              @RequestParam(value = "gender")Integer gender){
        return userService.insertUser(name,age,gender);
    }
}
